<?php
namespace app\home\Controller;
use think\Controller;
use think\Session;
use think\Db;

class Help extends Controller
{
    public function index()
    {
        // $user=db('user');
        // $data = array('userid' =>$_SESSION['userid'] ,
        //                'name' =>$_SESSION['yb_username'] ,
        //                'sex'=>$_SESSION['yb_sex'] ,
        //                'namehead'=>$_SESSION['yb_userhead'],
        //                );
        // $userid=$_SESSION['userid'];
        // $i=$user->where("userid=$userid")->count();
        // if($i==0){
        //  $user->add($data);
        //   }
        //   $userdata=M('userdata');  
        //   $dal=$userdata->select();
        //   // $time=$userdata->where("id=1")->getField('time');
        //   // echo strtotime($time);
          
         return $this->fetch();
    }
    public function dat()
    {
              // 指定允许其他域名访问  
        header('Access-Control-Allow-Origin:*');  
        // 响应类型  
        header('Access-Control-Allow-Methods:POST');  
        // 响应头设置  
        header('Access-Control-Allow-Headers:x-requested-with,content-type'); 
              $userdata=db('userdata'); 
      $dal=$userdata->select();
      if(empty($dal))
      {
         return json(['data'=>$dal,'code'=>0,'message'=>'系统错误，信息获取失败']);
      } 
      else
      
        return json(['data'=>$dal,'code'=>1,'message'=>'操作成功']);
    }
    public function data()
    {
      header('Access-Control-Allow-Origin:*');
      header('Access-Control-Allow-Methods:POST');  
      header('Access-Control-Allow-Headers:x-requested-with,content-type'); 
      $id=input('id');
      $userdata=db('userdata')->where('id=$id')->select();
      if(empty($userdata)){
        
        return json(['data'=>'','code'=>0,'message'=>'系统错误']);
      }
      
      else
      {
        return json(['data'=>$userdata,'code'=>1,'message'=>'操作成功']);
      }
    }
}